/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package assignmentbuilder;


import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;


/**
 *
 * @author keith
 */
public class Main {

  /**
   * @param args the command line arguments
   * @throws IOException
   */
    @SuppressWarnings("unchecked")
  public static void main( String[] args ) throws IOException {
    final ContentFile meta;

    final Set<ContentFile> set1 = new TreeSet<ContentFile>();
    set1.add( meta = new XMLContentFile( "assignment.xml" ) );
    set1.add( new ContentFile( "assignment.html" ) );

    final Set<ContentFile> set2 = new TreeSet<ContentFile>( set1 );
    set2.add( new ContentFile( "images/screenshot.png" ) );
    set2.add( new ContentFile( "images/interface.png" ) );

    final Set<ContentFile> set3 = new TreeSet<ContentFile>( set2 );
    set3.add( new ContentFile( "solution/DiceExperiment.java" ) );

    final Set<ContentFile> set4 = new TreeSet<ContentFile>( set2 );
    set4.add( new ContentFile( "solution/1/DiceExperiment.java" ) );
    set4.add( new ContentFile( "solution/2/DiceExperiment.java" ) );

    final Set<ContentFile> set5 = new TreeSet<ContentFile>( set4 );
    set5.add( new ContentFile( "software-tests/input1.txt" ) );
    set5.add( new ContentFile( "software-tests/input2.txt" ) );

    final Set<ContentFile> set6 = new TreeSet<ContentFile>( set4 );
    set6.add( new ContentFile( "software-tests/public/simple-ex-in.txt" ) );
    set6.add( new ContentFile( "software-tests/public/simple-ex-out.txt" ) );
    set6.add( new ContentFile( "software-tests/public/big-ex-in.txt" ) );
    set6.add( new ContentFile( "software-tests/public/big-ex-out.txt" ) );
    set6.add( new ContentFile( "software-tests/reference/input1.txt" ) );
    set6.add( new ContentFile( "software-tests/reference/expected-out1.txt" ) );
    set6.add( new ContentFile( "software-tests/reference/input2.txt" ) );
    set6.add( new ContentFile( "software-tests/reference/expected-out2.txt" ) );

    final Set<ContentFile> set7 = new TreeSet<ContentFile>( set6 );
    set7.add( new ContentFile( "start/.classpath" ) );
    set7.add( new ContentFile( "start/.project" ) );
    set7.add( new ContentFile( "start/build.xml" ) );
    set7.add( new ContentFile( "start/simple-ex-in.txt" ) );
    set7.add( new ContentFile( "start/DiceExperiment.java" ) );

    final List<Set<ContentFile>> sets = new ArrayList<Set<ContentFile>>();
    
//    @SuppressWarnings("unchecked")
    sets.addAll( Arrays.asList( (Set<ContentFile>[]) new Set[]{ set1, set2, set3, set4, set5, set6, set7 } ) );

    int idx = 0;
    for ( Set<ContentFile> s : sets ) {
      new AssignmentZipBuilder( s ).writeZipFile( "dist/a" + ++idx + ".zip" );
    }

    new FileOutputStream( "meta.xml" ).write( meta.getByes());
  }
}
